<html>
<head><meta charset="utf-8"><title>alignstack · project-inline-asm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/index.html">project-inline-asm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html">alignstack</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="183499592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/alignstack/near/183499592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html#183499592">(Dec 15 2019 at 18:54)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> What are your thoughts on adding the <code>alignstack</code> attribute? I would name it something like <code>uses_stack</code> and make it required if your asm code pushes to the stack.</p>



<a name="183499864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/alignstack/near/183499864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html#183499864">(Dec 15 2019 at 19:03)</a>:</h4>
<p>How much overhead does it add? Because that seems inconsistent with the safe-default approach used elsewhere, such as assuming earlyclobber and assuming clobbers of flags.</p>



<a name="183499870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/alignstack/near/183499870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html#183499870">(Dec 15 2019 at 19:03)</a>:</h4>
<p>Could we just default to alignstack, and (optionally) add a <code>nostack</code> flag or similar?</p>



<a name="183500076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/alignstack/near/183500076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html#183500076">(Dec 15 2019 at 19:09)</a>:</h4>
<p>It basically causes leaf functions to be treated as non-leaf functions.</p>



<a name="183500124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/alignstack/near/183500124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html#183500124">(Dec 15 2019 at 19:10)</a>:</h4>
<p>Basically it adds 2 instructions to the functions for the <code>esp</code> adjustment at the start &amp; end.</p>



<a name="183500130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/alignstack/near/183500130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html#183500130">(Dec 15 2019 at 19:10)</a>:</h4>
<p>And that's only on x86_64.</p>



<a name="183500135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/alignstack/near/183500135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html#183500135">(Dec 15 2019 at 19:10)</a>:</h4>
<p>I'm ok with reversing it to <code>nostack</code>.</p>



<a name="183502404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/alignstack/near/183502404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html#183502404">(Dec 15 2019 at 20:11)</a>:</h4>
<p>That seems reasonable to me. In particular, if you have a tiny leaf function that just contains inline assembly, you'll probably mark the whole function <code>#[inline]</code> so that it can be inlined into its caller, which eliminates that same overhead.</p>



<a name="183502452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/alignstack/near/183502452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/alignstack.html#183502452">(Dec 15 2019 at 20:12)</a>:</h4>
<p>And that seems like an excellent potential lint for future linting infrastructure that "understands" assembly: "it looks like this assembly could use <code>nostack</code>".</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>